<?php
/* wwwschool project
Copyright (C) 2009  Phillip Aldridge
Email : info@imi21.com
Web site http://www.imi21.com
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

/**
 *
 *  wwwschool project
 *  File : WS3lesson.php
 *  
 * CLASS WS3_Lesson
 */  
 
 class WS3_Lesson {
 
  private $lid = null; 
  private $course_id = null;
  private $name = null; 
  private $description = null; 
  private $active = false; 
  
  function __construct() {
   }
   
  function __destruct() {
   }
   
  // set Lesson id
  function setLessonID($id=null) {
    
    $dbLesson = new WS3_Database();
    $lesson_id = $dbLesson->makeSafeInt($id);   
    $q="SELECT *
    FROM `lesson`
    WHERE 1
    AND id= '$lesson_id'
    LIMIT 1";

    if ($dbLesson->query($q) && $dbLesson->nextRecord() )
    {
      $this->id = $dbLesson->f('id');
      $this->name = javaSafeString( $dbLesson->f('name') );
      $this->description = javaSafeString( $dbLesson->f('description') );
      $this->active = $dbLesson->f('active');
      $q="SELECT *
        FROM `lesson2course`
        WHERE 1
        AND id= '$lesson_id'
        LIMIT 1";
      $dbLesson2Course = new WS3_Database();
      if ( $dbLesson2Course->query($q) &&  $dbLesson2Course->nextRecord() )
      {
        $this->course_id = $dbLesson2Course->f('course_id');
      } 
      return true;
    }else{
      return false;
    }
   }
   
  // return Lesson id
  function LessonID() {
    if ($this->id)
    return $this->id;
    else
    return false; 
   }
   
  // return Course id
  function CourseID() {
    if ($this->course_id)
    return $this->course_id;
    else
    return false; 
   }    
  // return Lesson name
  function LessonName() {
    if ($this->name)
    return $this->name;
    else
    return false; 
   } 
   // return Lesson description
  function LessonDescription() {
    if ($this->description)
    return $this->description;
    else
    return false; 
   }   
 } // end class
 
 ?>
